package observerPattern;

import observerPattern.observerAPattern.CustomerOne;
import observerPattern.observerAPattern.CustomerTwo;
import observerPattern.observerAPattern.ShopSubject;
import observerPattern.observerBPattern.Person;
import observerPattern.observerBPattern.TravelAgency;
import observerPattern.observerBPattern.WeatherStation;
import org.junit.Test;

public class ApiTest {

    @Test
    public void test(){
        // 创建具体主题
        WeChatOfficialAccount weChatOfficialAccount  = new WeChatOfficialAccount();
        // 创建微信用户
        WeChatUser user1 = new WeChatUser("孙悟空");
        WeChatUser user2 = new WeChatUser("猪悟能");
        WeChatUser user3 = new WeChatUser("沙悟净");
        //订阅公众号
        weChatOfficialAccount.attach(user1);
        weChatOfficialAccount.attach(user2);
        weChatOfficialAccount.attach(user3);
        //公众号更新发出消息给订阅的微信用户
        weChatOfficialAccount.notify("来了！新闻早班车");
    }

    @Test
    public void test1(){
        ShopSubject shop = new ShopSubject();
        CustomerOne boy = new CustomerOne(shop, "张大三");
        CustomerTwo girl = new CustomerTwo(shop, "李红花");
        shop.setDiscountGoods("数码相机",2345.9,2008.8);
        shop.setDiscountGoods("手机",1236,998);
    }

    @Test
    public void test2(){
        WeatherStation weatherStation = new WeatherStation();
        TravelAgency travelAgency = new TravelAgency();
        Person person = new Person(weatherStation,travelAgency);
        weatherStation.doForecast("10日","阴有小雨",28,20);
        travelAgency.giveMess("10日","黄山二日游");
        weatherStation.doForecast("11日","阴转多云",30,22);
        travelAgency.giveMess("11日","丽江一日游");

    }
}

